From 9971f386b0b027c66ab86af6471a9fd694525f58 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 11 Apr 2010 20:26:49 +0200 Subject: [PATCH] GtkStyleSet: Add method to lookup property default settings. --- gtk/gtkstyleset.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstyleset.h | 3 +++ 2 files changed, 53 insertions(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index f91d3321ab..19e1a97f65 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -218,6 +218,56 @@ gtk_style_set_register_property (const gchar *property_name, g_array_insert_val (properties, i, new); } +gboolean +gtk_style_set_lookup_property (const gchar *property_name, + GType *type, + GValue *default_value) +{ + PropertyNode *node; + GtkStyleSetClass *klass; + GQuark quark; + GType t; + gint i; + + g_return_val_if_fail (property_name != NULL, FALSE); + + klass = g_type_class_ref (GTK_TYPE_STYLE_SET); + quark = g_quark_try_string (property_name); + + if (quark == 0) + { + g_type_class_unref (klass); + return FALSE; + } + + for (i = 0; i < properties->len; i++) + { + node = &g_array_index (properties, PropertyNode, i); + + if (node->property_quark == quark) + { + if (type) + *type = node->property_type; + + if (default_value) + { + g_value_init (default_value, G_VALUE_TYPE (&node->default_value)); + g_value_copy (&node->default_value, default_value); + } + + g_type_class_unref (klass); + + return TRUE; + } + else if (node->property_quark > quark) + break; + } + + g_type_class_unref (klass); + + return FALSE; +} + void gtk_style_set_register_property_color (const gchar *property_name, GdkColor *initial_value) diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 642dd02c31..16fda3ea78 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -55,6 +55,9 @@ GType gtk_style_set_get_type (void) G_GNUC_CONST; void gtk_style_set_register_property (const gchar *property_name, GType type, const GValue *default_value); +gboolean gtk_style_set_lookup_property (const gchar *property_name, + GType *type, + GValue *default_value); void gtk_style_set_register_property_color (const gchar *property_name, GdkColor *default_value); -- 2.30.2